package com.lyc.service.impl;

import com.lyc.beans.Book;
import com.lyc.mapper.BookMapper;
import com.lyc.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service
public class BookServiceImpl implements BookService {
    @Autowired
    private BookMapper bookMapper;

    //获取图书列表
    @Override
    public List<Book> getBooks() {
        return bookMapper.getBooks();
    }

    //添加图书
    @Override
    public void addBook(Book book) {
        bookMapper.addBook(book);
    }

    @Override
    public boolean checkBook(Book book) {
        int i = bookMapper.checkBook(book);
        if (i>0){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public void deleteBookById(Integer id) {
        bookMapper.deleteBookById(id);
    }

    @Override
    public Book getBookById(Integer id) {
        return bookMapper.getBookById(id);
    }

    @Override
    public Book getBookByName(Book book) {
        return bookMapper.getBookByName(book);
    }

    @Override
    public void updateBook(Book book1) {
        bookMapper.updateBook(book1);
    }
}
